package com.bjsxt.base.sync_shuoGG;

import java.text.SimpleDateFormat;
import java.util.Date;

public class NormalUtil {

    public synchronized void test1() {
        System.out.println(Thread.currentThread().getName() + " UseLock NormalUtil.test1 " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " ReleaseLock NormalUtil.test1 " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
    }

    public synchronized void test2() {
        System.out.println(Thread.currentThread().getName() + " UseLock NormalUtil.test2 " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " ReleaseLock NormalUtil.test2 " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
    }

}
